package com.code.generator.cn.util;

import com.code.generator.cn.entity.CoderTable;
import org.apache.commons.lang.StringUtils;

public class PathUtil {

    public static String getCreateBasePath(CoderTable coderTable) {
        String packageName;
        if(StringUtils.isNotEmpty(coderTable.getModalName())) {
            packageName = coderTable.getPackageName()+"."+coderTable.getModalName();
        }else{
            packageName = coderTable.getPackageName();
        }
        return packageName;
    }

    public static String createFileBasePath(CoderTable coderTable,String uploadPath){
        String packageName=coderTable.getPackageName();
        String groupPath=packageName.replace(".","/");
        String entityPath="";
        if(StringUtils.isEmpty(coderTable.getModalName())){
            entityPath= uploadPath+"/src/main/java/"+groupPath;
        }else{
            entityPath= uploadPath+"/src/main/java/"+groupPath+"/"+coderTable.getModalName()+"/";
        }
        return entityPath;
    }


    public static Object createPackageName(CoderTable coderTable) {

        if(StringUtils.isEmpty(coderTable.getModalName())){
            return coderTable.getPackageName();
        }else{
            return  coderTable.getPackageName()+"."+StringUtils.uncapitalize(coderTable.getModalName());
        }

    }
}
